//引入router
import router from './index.js'
//引入store
import store from '../store/index.js'
//路由守卫
router.beforeEach((to,from,next)=>{
    //1.判断是否需要登录
    if(to.matched.some(item=>item.meta.isLogin)){//需要登录
      //2. 判断需要登录  是否已经登录
      let token =store.state.loginModules.userinfo.token;
      if(token){
        next()
      }else{
        next('/login')
      }
    }else{
      // console.log('不需要登录');
      next()
    }
  })